From 3b09cd5473409bcd6b42530759684cbfe6074ea0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 15 Jan 2015 12:17:18 -0800 Subject: [PATCH] Actually use absolute paths for crates.io crates Turns out path_relative_from returns Some even if they're not ancestors of one another! This adds an explicit check for `is_ancestor_of`. --- src/cargo/ops/cargo_rustc/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 95b492634..a61fddb36 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -631,7 +631,12 @@ fn rustdoc(package: &Package, target: &Target, // absolute paths instead of relative paths. fn root_path(cx: &Context, pkg: &Package, target: &Target) -> Path { let absolute = pkg.get_root().join(target.get_src_path()); - absolute.path_relative_from(cx.config.cwd()).unwrap_or(absolute) + let cwd = cx.config.cwd(); + if cwd.is_ancestor_of(&absolute) { + absolute.path_relative_from(cwd).unwrap_or(absolute) + } else { + absolute + } } fn build_base_args(cx: &Context, -- 2.30.2